{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_excel('/Users/liuyang/Desktop/中科院/共享杯/气候小项目/cdd.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>月份</th>\n",
       "      <th>广州</th>\n",
       "      <th>深圳</th>\n",
       "      <th>东菀</th>\n",
       "      <th>江门</th>\n",
       "      <th>佛山</th>\n",
       "      <th>中山</th>\n",
       "      <th>惠州</th>\n",
       "      <th>珠海</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1996</td>\n",
       "      <td>6</td>\n",
       "      <td>36.0719</td>\n",
       "      <td>46.8207</td>\n",
       "      <td>47.3077</td>\n",
       "      <td>58.9380</td>\n",
       "      <td>2.9669</td>\n",
       "      <td>49.0985</td>\n",
       "      <td>41.1356</td>\n",
       "      <td>49.5781</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1996</td>\n",
       "      <td>7</td>\n",
       "      <td>50.8450</td>\n",
       "      <td>55.5054</td>\n",
       "      <td>61.7297</td>\n",
       "      <td>66.8636</td>\n",
       "      <td>6.2353</td>\n",
       "      <td>56.5800</td>\n",
       "      <td>39.4428</td>\n",
       "      <td>56.7164</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1996</td>\n",
       "      <td>8</td>\n",
       "      <td>51.9712</td>\n",
       "      <td>56.9867</td>\n",
       "      <td>60.2469</td>\n",
       "      <td>74.4609</td>\n",
       "      <td>15.2822</td>\n",
       "      <td>63.3000</td>\n",
       "      <td>48.4641</td>\n",
       "      <td>66.2264</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1997</td>\n",
       "      <td>6</td>\n",
       "      <td>36.6894</td>\n",
       "      <td>43.1151</td>\n",
       "      <td>46.3588</td>\n",
       "      <td>53.0371</td>\n",
       "      <td>3.8021</td>\n",
       "      <td>51.6005</td>\n",
       "      <td>42.1229</td>\n",
       "      <td>38.0656</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1997</td>\n",
       "      <td>7</td>\n",
       "      <td>56.7954</td>\n",
       "      <td>70.9001</td>\n",
       "      <td>72.9636</td>\n",
       "      <td>82.9925</td>\n",
       "      <td>12.0502</td>\n",
       "      <td>64.7695</td>\n",
       "      <td>57.3782</td>\n",
       "      <td>71.2136</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  月份       广州       深圳       东菀       江门       佛山       中山       惠州  \\\n",
       "0  1996   6  36.0719  46.8207  47.3077  58.9380   2.9669  49.0985  41.1356   \n",
       "1  1996   7  50.8450  55.5054  61.7297  66.8636   6.2353  56.5800  39.4428   \n",
       "2  1996   8  51.9712  56.9867  60.2469  74.4609  15.2822  63.3000  48.4641   \n",
       "3  1997   6  36.6894  43.1151  46.3588  53.0371   3.8021  51.6005  42.1229   \n",
       "4  1997   7  56.7954  70.9001  72.9636  82.9925  12.0502  64.7695  57.3782   \n",
       "\n",
       "        珠海  \n",
       "0  49.5781  \n",
       "1  56.7164  \n",
       "2  66.2264  \n",
       "3  38.0656  \n",
       "4  71.2136  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    36.0719\n",
       "1    50.8450\n",
       "2    51.9712\n",
       "Name: 广州, dtype: float64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['广州'][0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "#计算六月份的平均\n",
    "t = [0,0,0]\n",
    "for i in range(0,30):\n",
    "    t = t+data['广州'][i*3:i*3+3]\n",
    "    \n",
    "tt = t/30"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    37.0719\n",
       "1    51.8450\n",
       "2    52.9712\n",
       "Name: 广州, dtype: float64"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t = [1,1,1]\n",
    "t+data['广州'][0:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3    36.6894\n",
       "4    56.7954\n",
       "5    70.4925\n",
       "Name: 广州, dtype: float64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i = 1\n",
    "data['广州'][i*3:i*3+3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
